package servlet;

import dao.UserDAO1;
import entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name="PersonFindByName", value = "/admin/findByName")
public class PersonFindByName extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 根据id传回用户信息
        String username = req.getParameter("username");
        UserDAO1 userDAO1 = new UserDAO1();
        User user = userDAO1.findByName(username);
        req.setAttribute("person", user);  // 设置属性
        req.getRequestDispatcher("/person/personal.jsp").forward(req,resp);
        System.out.println(user);
    }
}
